package lab3;

import lab2.FDVisitor;
import lab2.HRVisitor;
import lab2.VisitorInterface;

import java.lang.reflect.InvocationTargetException;

public class VisitorFactory {
    public static VisitorInterface getVisitor(String name){
        Class<?> clz = null;
        try {
            clz = Class.forName("lab2."+name);
            Object obj = clz.getDeclaredConstructor().newInstance();
            return (VisitorInterface) obj;
        } catch (ClassNotFoundException | InstantiationException | IllegalAccessException e) {
            throw new RuntimeException(e);
        } catch (InvocationTargetException e) {
            throw new RuntimeException(e);
        } catch (NoSuchMethodException e) {
            throw new RuntimeException(e);
        }
    }
}
